<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>
  Hantsy
  
  Bai
  
  
  | Deploying Jakarta EE 9 applications to Apache TomEE using Cargo maven plugin
  
</title>
<meta name="description" content="My personal website focusing on Java EE/Jakarta EE and Spring.
">

<!-- Open Graph -->


<!-- Bootstrap & MDB -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
  rel="stylesheet" integrity="sha512-MoRNloxbStBcD8z3M/2BmnT+rg4IsMxPkXaGh2zD6LGNNFE80W3onsAhRcMAMrSoyWL9xD7Ert0men7vR8LUZg==" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.19.1/css/mdb.min.css"
  integrity="sha512-RO38pBRxYH3SoOprtPTD86JFOclM51/XTIdEPh5j8sj4tp8jmQIx26twG52UaLi//hQldfrh7e51WzP9wuP32Q==" crossorigin="anonymous" />

<!-- Fonts & Icons -->
<link rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css"
  integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous">
<link rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/academicons/1.9.0/css/academicons.min.css"
  integrity="sha512-W4yqoT1+8NLkinBLBZko+dFB2ZbHsYLDdr50VElllRcNt2Q4/GSs6u71UHKxB7S6JEMCp5Ve4xjh3eGQl/HRvg==" crossorigin="anonymous">
<link rel="stylesheet" type="text/css"
  href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:100,300,400,500,700|Material+Icons">

<!-- Code Syntax Highlighting -->
<link rel="stylesheet"
  href="https://gitcdn.link/repo/jwarby/jekyll-pygments-themes/master/github.css" />

<!-- Styles -->
<link rel="shortcut icon" href="/assets/img/favicon.ico">
<link rel="stylesheet" href="/assets/css/main.css">

<link rel="canonical" href="/blog/2020/deploying-jakarta-ee-9-applications-to-apache-tomee-using-cargo-maven-plugin/">

<!-- JQuery -->
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>


<!-- Theming-->

<script src="/assets/js/theme.js"></script>
<!-- Load DarkMode JS -->
<script src="/assets/js/dark_mode.js"></script>



<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-18SZ2W3GXD"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments); }
  gtag('js', new Date());

  gtag('config', 'G-18SZ2W3GXD');
</script>




  
<!-- MathJax -->
<script type="text/javascript">
  window.MathJax = {
    tex: {
      tags: 'ams'
    }
  };
</script>
<script defer type="text/javascript" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3.1.2/es5/tex-mml-chtml.js"></script>
<script defer src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>


  <link type="application/atom+xml" rel="alternate" href="/feed.xml" title="blank" />
  <!-- Begin Jekyll SEO tag v2.7.1 -->
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="Deploying Jakarta EE 9 applications to Apache TomEE using Cargo maven plugin" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="In addition to Deploying Jakarta EE 9 applications to Apache TomEE, in this post using Cargo Maven Plugin instead. We have discussed the deployment to Apache TomEE using the official tomee-maven-plugin. With tomee-maven-plugin, it is easy to download a copy of Apache TomEE distribution and start the TomEE server and then deploy the application to it. Or deploy your application to a running TomEE server. The official maven plugin is great for most cases, but it lacks the ability to deploy the application to a local installed server with fine-grained configurations. Cargo maven plugin 1.8.3 brought updates to TomEE 9.0 which is aligned to Jakarta EE 9, there are several deployment options. Deploy to a local TomEE server with a standalone configurationDeploy to a local TomEE server with a existing configurationDeploy to a running TomEE server with a runtime configuration Prerequisites Make sure you have installed the following software. Java 8 or Java 11 (OpenJDK or AdoptOpenJDK)Apache TomEE (Plume) 9.0.0-M3Apache MavenGet to know the basic of Cargo maven plugin. Deploy to local TomEE server The following configuration is using a local installed server with a standalone configuration. &lt;profile&gt; &lt;id&gt;tomee-local&lt;/id&gt; &lt;properties&gt; &lt;tomee.home&gt;${project.build.directory}/apache-tomee-plume-${tomee.version}&lt;/tomee.home&gt; &lt;/properties&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;unpack&lt;/id&gt; &lt;phase&gt;process-resources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;unpack&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;artifactItems&gt; &lt;artifactItem&gt; &lt;groupId&gt;org.apache.tomee.jakarta&lt;/groupId&gt; &lt;artifactId&gt;apache-tomee&lt;/artifactId&gt; &lt;version&gt;${tomee.version}&lt;/version&gt; &lt;classifier&gt;plume&lt;/classifier&gt; &lt;type&gt;zip&lt;/type&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;/artifactItems&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;tomee9x&lt;/containerId&gt; &lt;type&gt;installed&lt;/type&gt; &lt;home&gt;${tomee.home}&lt;/home&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;standalone&lt;/type&gt; &lt;properties&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt;&lt;/profile&gt; In this configuration, we use dependency maven plugin to prepare a TomEE server for you, of course you can use the local existing server instead. In the container section, used a installed type, and specify the home to the location of the TomEE server. In the configuration section, we use a standalone configuration here. More details about the TomEE properties, see the Cargo TomEE 9.x container page. Run the following command to deploy our application. mvn clean package cargo:run -Ptomee-local It will perform a series of tasks, including: Build the project and packaged it into a war in the target folder.Download a copy of Apache TomEE, and extract the files to the target folder.Then create a new standalone configuration in the target folder which is only use for this application.Start the TomEE server using the created standalone configuration.Finally deploy the war to the running server. By default, Apache Tomcat and Apache TomEE do not contain configurations for multi domains/instances, but it is possible, there are lots of articles in Google search results. The cargo generated standalone configuration is an example for configuring a new instance. If you want to reuse the default configuration in the TomEE server, change the configuraiton section to the following. &lt;configuration&gt; &lt;type&gt;existing&lt;/type&gt; &lt;home&gt;&lt;/home&gt;&lt;/configuration&gt; In this configuration, set the type value to existing, and the home is same as home in the container section, because there is no specifical configurations for domain instances like Glassfish. To undeploy the application, just send a CTRL+C to the console. Deploy to a running TomEE server To deploy to a running TomEE server, esp. it is located in a different host, using the following configuration instead. &lt;profile&gt; &lt;id&gt;tomee-remote&lt;/id&gt; &lt;!-- Add `manager-script` role to the tomee user in tomee/conf/tomcat-users.xml --&gt; &lt;!-- Run `mvn clean cargo:deploy -Ptomee-remote` to the running TomEE--&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;tomee9x&lt;/containerId&gt; &lt;type&gt;remote&lt;/type&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;runtime&lt;/type&gt; &lt;properties&gt; &lt;cargo.remote.username&gt;tomee&lt;/cargo.remote.username&gt; &lt;cargo.remote.password&gt;tomee&lt;/cargo.remote.password&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/profile&gt; In this configuration, in the container section, set the type to remote, and in the configuration section set type to runtime, and do not forget set username and password used to connect the remote server. Similar to Apache Tomcat, Cargo also requires the configured user has a manager-script role. Open the tomee dir/conf/tomcat-users.xml file, make sure manager-script is set in the roles. &lt;user username=&quot;tomee&quot; password=&quot;tomee&quot; roles=&quot;tomee-admin,manager-gui,manager-script&quot; /&gt; Run the following command to deploy and undeploy the applications. # deploy applicationsmvn clean package cargo:deploy -Ptomee-remote # undeploymvn cargo:undeploy -Ptomee-remote Grab the source codes from my Github. &lt;hr&gt;&lt;p&gt;Deploying Jakarta EE 9 applications to Apache TomEE using Cargo maven plugin was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.&lt;/p&gt;" />
<meta property="og:description" content="In addition to Deploying Jakarta EE 9 applications to Apache TomEE, in this post using Cargo Maven Plugin instead. We have discussed the deployment to Apache TomEE using the official tomee-maven-plugin. With tomee-maven-plugin, it is easy to download a copy of Apache TomEE distribution and start the TomEE server and then deploy the application to it. Or deploy your application to a running TomEE server. The official maven plugin is great for most cases, but it lacks the ability to deploy the application to a local installed server with fine-grained configurations. Cargo maven plugin 1.8.3 brought updates to TomEE 9.0 which is aligned to Jakarta EE 9, there are several deployment options. Deploy to a local TomEE server with a standalone configurationDeploy to a local TomEE server with a existing configurationDeploy to a running TomEE server with a runtime configuration Prerequisites Make sure you have installed the following software. Java 8 or Java 11 (OpenJDK or AdoptOpenJDK)Apache TomEE (Plume) 9.0.0-M3Apache MavenGet to know the basic of Cargo maven plugin. Deploy to local TomEE server The following configuration is using a local installed server with a standalone configuration. &lt;profile&gt; &lt;id&gt;tomee-local&lt;/id&gt; &lt;properties&gt; &lt;tomee.home&gt;${project.build.directory}/apache-tomee-plume-${tomee.version}&lt;/tomee.home&gt; &lt;/properties&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;unpack&lt;/id&gt; &lt;phase&gt;process-resources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;unpack&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;artifactItems&gt; &lt;artifactItem&gt; &lt;groupId&gt;org.apache.tomee.jakarta&lt;/groupId&gt; &lt;artifactId&gt;apache-tomee&lt;/artifactId&gt; &lt;version&gt;${tomee.version}&lt;/version&gt; &lt;classifier&gt;plume&lt;/classifier&gt; &lt;type&gt;zip&lt;/type&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;/artifactItems&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;tomee9x&lt;/containerId&gt; &lt;type&gt;installed&lt;/type&gt; &lt;home&gt;${tomee.home}&lt;/home&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;standalone&lt;/type&gt; &lt;properties&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt;&lt;/profile&gt; In this configuration, we use dependency maven plugin to prepare a TomEE server for you, of course you can use the local existing server instead. In the container section, used a installed type, and specify the home to the location of the TomEE server. In the configuration section, we use a standalone configuration here. More details about the TomEE properties, see the Cargo TomEE 9.x container page. Run the following command to deploy our application. mvn clean package cargo:run -Ptomee-local It will perform a series of tasks, including: Build the project and packaged it into a war in the target folder.Download a copy of Apache TomEE, and extract the files to the target folder.Then create a new standalone configuration in the target folder which is only use for this application.Start the TomEE server using the created standalone configuration.Finally deploy the war to the running server. By default, Apache Tomcat and Apache TomEE do not contain configurations for multi domains/instances, but it is possible, there are lots of articles in Google search results. The cargo generated standalone configuration is an example for configuring a new instance. If you want to reuse the default configuration in the TomEE server, change the configuraiton section to the following. &lt;configuration&gt; &lt;type&gt;existing&lt;/type&gt; &lt;home&gt;&lt;/home&gt;&lt;/configuration&gt; In this configuration, set the type value to existing, and the home is same as home in the container section, because there is no specifical configurations for domain instances like Glassfish. To undeploy the application, just send a CTRL+C to the console. Deploy to a running TomEE server To deploy to a running TomEE server, esp. it is located in a different host, using the following configuration instead. &lt;profile&gt; &lt;id&gt;tomee-remote&lt;/id&gt; &lt;!-- Add `manager-script` role to the tomee user in tomee/conf/tomcat-users.xml --&gt; &lt;!-- Run `mvn clean cargo:deploy -Ptomee-remote` to the running TomEE--&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;tomee9x&lt;/containerId&gt; &lt;type&gt;remote&lt;/type&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;runtime&lt;/type&gt; &lt;properties&gt; &lt;cargo.remote.username&gt;tomee&lt;/cargo.remote.username&gt; &lt;cargo.remote.password&gt;tomee&lt;/cargo.remote.password&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/profile&gt; In this configuration, in the container section, set the type to remote, and in the configuration section set type to runtime, and do not forget set username and password used to connect the remote server. Similar to Apache Tomcat, Cargo also requires the configured user has a manager-script role. Open the tomee dir/conf/tomcat-users.xml file, make sure manager-script is set in the roles. &lt;user username=&quot;tomee&quot; password=&quot;tomee&quot; roles=&quot;tomee-admin,manager-gui,manager-script&quot; /&gt; Run the following command to deploy and undeploy the applications. # deploy applicationsmvn clean package cargo:deploy -Ptomee-remote # undeploymvn cargo:undeploy -Ptomee-remote Grab the source codes from my Github. &lt;hr&gt;&lt;p&gt;Deploying Jakarta EE 9 applications to Apache TomEE using Cargo maven plugin was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.&lt;/p&gt;" />
<meta property="og:site_name" content="blank" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2020-12-17T00:00:00+00:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Deploying Jakarta EE 9 applications to Apache TomEE using Cargo maven plugin" />
<script type="application/ld+json">
{"datePublished":"2020-12-17T00:00:00+00:00","description":"In addition to Deploying Jakarta EE 9 applications to Apache TomEE, in this post using Cargo Maven Plugin instead. We have discussed the deployment to Apache TomEE using the official tomee-maven-plugin. With tomee-maven-plugin, it is easy to download a copy of Apache TomEE distribution and start the TomEE server and then deploy the application to it. Or deploy your application to a running TomEE server. The official maven plugin is great for most cases, but it lacks the ability to deploy the application to a local installed server with fine-grained configurations. Cargo maven plugin 1.8.3 brought updates to TomEE 9.0 which is aligned to Jakarta EE 9, there are several deployment options. Deploy to a local TomEE server with a standalone configurationDeploy to a local TomEE server with a existing configurationDeploy to a running TomEE server with a runtime configuration Prerequisites Make sure you have installed the following software. Java 8 or Java 11 (OpenJDK or AdoptOpenJDK)Apache TomEE (Plume) 9.0.0-M3Apache MavenGet to know the basic of Cargo maven plugin. Deploy to local TomEE server The following configuration is using a local installed server with a standalone configuration. &lt;profile&gt; &lt;id&gt;tomee-local&lt;/id&gt; &lt;properties&gt; &lt;tomee.home&gt;${project.build.directory}/apache-tomee-plume-${tomee.version}&lt;/tomee.home&gt; &lt;/properties&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;unpack&lt;/id&gt; &lt;phase&gt;process-resources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;unpack&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;artifactItems&gt; &lt;artifactItem&gt; &lt;groupId&gt;org.apache.tomee.jakarta&lt;/groupId&gt; &lt;artifactId&gt;apache-tomee&lt;/artifactId&gt; &lt;version&gt;${tomee.version}&lt;/version&gt; &lt;classifier&gt;plume&lt;/classifier&gt; &lt;type&gt;zip&lt;/type&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;/artifactItems&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;tomee9x&lt;/containerId&gt; &lt;type&gt;installed&lt;/type&gt; &lt;home&gt;${tomee.home}&lt;/home&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;standalone&lt;/type&gt; &lt;properties&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt;&lt;/profile&gt; In this configuration, we use dependency maven plugin to prepare a TomEE server for you, of course you can use the local existing server instead. In the container section, used a installed type, and specify the home to the location of the TomEE server. In the configuration section, we use a standalone configuration here. More details about the TomEE properties, see the Cargo TomEE 9.x container page. Run the following command to deploy our application. mvn clean package cargo:run -Ptomee-local It will perform a series of tasks, including: Build the project and packaged it into a war in the target folder.Download a copy of Apache TomEE, and extract the files to the target folder.Then create a new standalone configuration in the target folder which is only use for this application.Start the TomEE server using the created standalone configuration.Finally deploy the war to the running server. By default, Apache Tomcat and Apache TomEE do not contain configurations for multi domains/instances, but it is possible, there are lots of articles in Google search results. The cargo generated standalone configuration is an example for configuring a new instance. If you want to reuse the default configuration in the TomEE server, change the configuraiton section to the following. &lt;configuration&gt; &lt;type&gt;existing&lt;/type&gt; &lt;home&gt;&lt;/home&gt;&lt;/configuration&gt; In this configuration, set the type value to existing, and the home is same as home in the container section, because there is no specifical configurations for domain instances like Glassfish. To undeploy the application, just send a CTRL+C to the console. Deploy to a running TomEE server To deploy to a running TomEE server, esp. it is located in a different host, using the following configuration instead. &lt;profile&gt; &lt;id&gt;tomee-remote&lt;/id&gt; &lt;!-- Add `manager-script` role to the tomee user in tomee/conf/tomcat-users.xml --&gt; &lt;!-- Run `mvn clean cargo:deploy -Ptomee-remote` to the running TomEE--&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt; &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt; &lt;configuration&gt; &lt;container&gt; &lt;containerId&gt;tomee9x&lt;/containerId&gt; &lt;type&gt;remote&lt;/type&gt; &lt;/container&gt; &lt;configuration&gt; &lt;type&gt;runtime&lt;/type&gt; &lt;properties&gt; &lt;cargo.remote.username&gt;tomee&lt;/cargo.remote.username&gt; &lt;cargo.remote.password&gt;tomee&lt;/cargo.remote.password&gt; &lt;/properties&gt; &lt;/configuration&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/profile&gt; In this configuration, in the container section, set the type to remote, and in the configuration section set type to runtime, and do not forget set username and password used to connect the remote server. Similar to Apache Tomcat, Cargo also requires the configured user has a manager-script role. Open the tomee dir/conf/tomcat-users.xml file, make sure manager-script is set in the roles. &lt;user username=&quot;tomee&quot; password=&quot;tomee&quot; roles=&quot;tomee-admin,manager-gui,manager-script&quot; /&gt; Run the following command to deploy and undeploy the applications. # deploy applicationsmvn clean package cargo:deploy -Ptomee-remote # undeploymvn cargo:undeploy -Ptomee-remote Grab the source codes from my Github. &lt;hr&gt;&lt;p&gt;Deploying Jakarta EE 9 applications to Apache TomEE using Cargo maven plugin was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.&lt;/p&gt;","mainEntityOfPage":{"@type":"WebPage","@id":"/blog/2020/deploying-jakarta-ee-9-applications-to-apache-tomee-using-cargo-maven-plugin/"},"url":"/blog/2020/deploying-jakarta-ee-9-applications-to-apache-tomee-using-cargo-maven-plugin/","@type":"BlogPosting","headline":"Deploying Jakarta EE 9 applications to Apache TomEE using Cargo maven plugin","dateModified":"2020-12-17T00:00:00+00:00","@context":"https://schema.org"}</script>
<!-- End Jekyll SEO tag -->

</head>

<body
  class="fixed-top-nav ">

  <!-- Header -->

  <header>

    <!-- Nav Bar -->
    <nav id="navbar" class="navbar navbar-light navbar-expand-sm fixed-top">
    <div class="container">
      
      <a class="navbar-brand title font-weight-lighter" href="/">
       <span class="font-weight-bold">Hantsy</span>   Bai
      </a>
      
      <!-- Navbar Toggle -->
      <button class="navbar-toggler collapsed ml-auto" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar top-bar"></span>
        <span class="icon-bar middle-bar"></span>
        <span class="icon-bar bottom-bar"></span>
      </button>
      <div class="collapse navbar-collapse text-right" id="navbarNav">
        <ul class="navbar-nav ml-auto flex-nowrap">
          <!-- About -->
          <li class="nav-item ">
            <a class="nav-link" href="/">
              about
              
            </a>
          </li>
          
          <!-- Blog -->
          <li class="nav-item active">
            <a class="nav-link" href="/blog/">
              blog
              
            </a>
          </li>
          
          <!-- Other pages -->
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          <li class="nav-item ">
              <a class="nav-link" href="/projects/">
                projects
                
              </a>
          </li>
          
          
          
          <li class="nav-item ">
              <a class="nav-link" href="/publications/">
                publications
                
              </a>
          </li>
          
          
          
          <li class="nav-item ">
              <a class="nav-link" href="/service/">
                service
                
              </a>
          </li>
          
          
          
            <div class = "toggle-container">
              <a id = "light-toggle">
                  <i class="fas fa-moon"></i>
                  <i class="fas fa-sun"></i>
              </a>
            </div>
          
        </ul>
      </div>
    </div>
  </nav>

</header>


  <!-- Content -->

  <div class="container mt-5">
    

<div class="post">

  <header class="post-header">
    <h1 class="post-title">Deploying Jakarta EE 9 applications to Apache TomEE using Cargo maven plugin</h1>
    <p class="post-meta">December 17, 2020</p>
  </header>

  <article class="post-content">
    <p>In addition to <a href="https://itnext.io/deploying-jakarta-ee-9-applications-to-apache-tomee-e1a9b9399d9b">Deploying Jakarta EE 9 applications to Apache TomEE,</a> in this post using Cargo Maven Plugin instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XZgar-TMaqJ9r-ovXsLz_A.png" /></figure><p>We have discussed the <a href="https://github.com/hantsy/jakartaee9-starter-boilerplate/blob/master/docs/deploy-tomee.md">deployment to Apache TomEE</a> using the official tomee-maven-plugin. With tomee-maven-plugin, it is easy to download a copy of Apache TomEE distribution and start the TomEE server and then deploy the application to it. Or deploy your application to a running TomEE server. The official maven plugin is great for most cases, but it lacks the ability to deploy the application to a local installed server with fine-grained configurations.</p><p>Cargo maven plugin 1.8.3 brought updates to TomEE 9.0 which is aligned to Jakarta EE 9, there are several deployment options.</p><ul><li>Deploy to a local TomEE server with a standalone configuration</li><li>Deploy to a local TomEE server with a existing configuration</li><li>Deploy to a running TomEE server with a runtime configuration</li></ul><h3>Prerequisites</h3><p>Make sure you have installed the following software.</p><ul><li>Java 8 or Java 11 (<a href="https://openjdk.java.net/install/">OpenJDK</a> or <a href="https://adoptopenjdk.net/installation.html">AdoptOpenJDK</a>)</li><li><a href="http://tomee.apache.org/download-ng.html">Apache TomEE (Plume) 9.0.0-M3</a></li><li><a href="http://maven.apache.org/">Apache Maven</a></li><li>Get to know the basic of <a href="https://codehaus-cargo.github.io/">Cargo maven plugin</a>.</li></ul><h3>Deploy to local TomEE server</h3><p>The following configuration is using a local installed server with a <strong>standalone</strong> configuration.</p><pre>&lt;profile&gt;<br>    &lt;id&gt;tomee-local&lt;/id&gt;<br>    &lt;properties&gt;<br>        &lt;tomee.home&gt;${project.build.directory}/apache-tomee-plume-${tomee.version}&lt;/tomee.home&gt;<br>    &lt;/properties&gt;<br>    &lt;build&gt;<br>        &lt;plugins&gt;<br>            &lt;plugin&gt;<br>                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>                &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;<br>                &lt;executions&gt;<br>                    &lt;execution&gt;<br>                        &lt;id&gt;unpack&lt;/id&gt;<br>                        &lt;phase&gt;process-resources&lt;/phase&gt;<br>                        &lt;goals&gt;<br>                            &lt;goal&gt;unpack&lt;/goal&gt;<br>                        &lt;/goals&gt;<br>                        &lt;configuration&gt;<br>                            &lt;artifactItems&gt;<br>                                &lt;artifactItem&gt;<br>                                    &lt;groupId&gt;org.apache.tomee.jakarta&lt;/groupId&gt;<br>                                    &lt;artifactId&gt;apache-tomee&lt;/artifactId&gt;<br>                                    &lt;version&gt;${tomee.version}&lt;/version&gt;<br>                                    &lt;classifier&gt;plume&lt;/classifier&gt;<br>                                    &lt;type&gt;zip&lt;/type&gt;<br>                                    &lt;overWrite&gt;false&lt;/overWrite&gt;<br>                                    &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt;<br>                                &lt;/artifactItem&gt;<br>                            &lt;/artifactItems&gt;<br>                        &lt;/configuration&gt;<br>                    &lt;/execution&gt;<br>                &lt;/executions&gt;<br>            &lt;/plugin&gt;<br>            &lt;plugin&gt;<br>                &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt;<br>                &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt;<br>                &lt;configuration&gt;<br>                    &lt;container&gt;<br>                        &lt;containerId&gt;tomee9x&lt;/containerId&gt;<br>                        &lt;type&gt;installed&lt;/type&gt;<br>                        &lt;home&gt;${tomee.home}&lt;/home&gt;<br>                    &lt;/container&gt;<br>                    &lt;configuration&gt;<br>                        &lt;type&gt;standalone&lt;/type&gt;<br>                        &lt;properties&gt;<br>                        &lt;/properties&gt;<br>                    &lt;/configuration&gt;<br>                &lt;/configuration&gt;<br>            &lt;/plugin&gt;<br>        &lt;/plugins&gt;<br>    &lt;/build&gt;<br>&lt;/profile&gt;</pre><p>In this configuration, we use dependency maven plugin to prepare a TomEE server for you, of course you can use the local existing server instead.</p><p>In the container section, used a <strong>installed</strong> type, and specify the <em>home</em> to the <strong>location of the TomEE server</strong>.</p><p>In the configuration section, we use a <strong>standalone</strong> configuration here.</p><blockquote><em>More details about the TomEE properties, see the </em><a href="https://codehaus-cargo.github.io/cargo/TomEE+9.x.html"><em>Cargo TomEE 9.x container page</em></a><em>.</em></blockquote><p>Run the following command to deploy our application.</p><pre>mvn clean package cargo:run -Ptomee-local</pre><p>It will perform a series of tasks, including:</p><ul><li>Build the project and packaged it into a war in the target folder.</li><li>Download a copy of Apache TomEE, and extract the files to the target folder.</li><li>Then create a new <strong>standalone</strong> configuration in the target folder which is only use for this application.</li><li>Start the TomEE server using the created <strong>standalone</strong> configuration.</li><li>Finally deploy the war to the running server.</li></ul><blockquote><em>By default, Apache Tomcat and Apache TomEE do not contain configurations for multi domains/instances, but it is possible, there are lots of articles in </em><a href="https://www.google.com/search?client=firefox-b-d&amp;q=tomcat+multi+instance"><em>Google search results</em></a><em>. The cargo generated </em><strong><em>standalone</em></strong><em> configuration is an example for configuring a new instance.</em></blockquote><p>If you want to reuse the default configuration in the TomEE server, change the configuraiton section to the following.</p><pre>&lt;configuration&gt;<br>    &lt;type&gt;existing&lt;/type&gt;<br>    &lt;home&gt;&lt;/home&gt;<br>&lt;/configuration&gt;</pre><p>In this configuration, set the type value to <strong>existing</strong>, and the <em>home</em> is same as home in the container section, because there is no specifical configurations for domain instances like Glassfish.</p><p>To undeploy the application, just send a CTRL+C to the console.</p><h3>Deploy to a running TomEE server</h3><p>To deploy to a running TomEE server, esp. it is located in a different host, using the following configuration instead.</p><pre>&lt;profile&gt;<br>    &lt;id&gt;tomee-remote&lt;/id&gt;<br>    &lt;!-- Add `manager-script` role to the tomee user in tomee/conf/tomcat-users.xml --&gt;<br>    &lt;!-- Run `mvn clean cargo:deploy -Ptomee-remote` to the running TomEE--&gt;<br>    &lt;build&gt;<br>        &lt;plugins&gt;<br>            &lt;plugin&gt;<br>                &lt;groupId&gt;org.codehaus.cargo&lt;/groupId&gt;<br>                &lt;artifactId&gt;cargo-maven2-plugin&lt;/artifactId&gt;<br>                &lt;configuration&gt;<br>                    &lt;container&gt;<br>                        &lt;containerId&gt;tomee9x&lt;/containerId&gt;<br>                        &lt;type&gt;remote&lt;/type&gt;<br>                    &lt;/container&gt;<br>                    &lt;configuration&gt;<br>                        &lt;type&gt;runtime&lt;/type&gt;<br>                        &lt;properties&gt;<br>                            &lt;cargo.remote.username&gt;tomee&lt;/cargo.remote.username&gt;<br>                            &lt;cargo.remote.password&gt;tomee&lt;/cargo.remote.password&gt;<br>                        &lt;/properties&gt;<br>                    &lt;/configuration&gt;<br>                &lt;/configuration&gt;<br>            &lt;/plugin&gt;<br>        &lt;/plugins&gt;<br>    &lt;/build&gt;<br>        &lt;/profile&gt;</pre><p>In this configuration, in the container section, set the type to <strong>remote</strong>, and in the configuration section set type to runtime, and do not forget set username and password used to connect the remote server.</p><p>Similar to Apache Tomcat, Cargo also requires the configured user has a <strong>manager-script</strong> role. Open the <em>tomee dir/conf/tomcat-users.xml</em> file, make sure <strong>manager-script</strong> is set in the roles.</p><pre>&lt;user username=&quot;tomee&quot; password=&quot;tomee&quot; roles=&quot;tomee-admin,manager-gui,manager-script&quot; /&gt;</pre><p>Run the following command to deploy and undeploy the applications.</p><pre># deploy applications<br>mvn clean package cargo:deploy -Ptomee-remote</pre><pre># undeploy<br>mvn cargo:undeploy -Ptomee-remote</pre><p><strong>Grab</strong><a href="https://github.com/hantsy/jakartaee9-starter-boilerplate"><strong> the source codes from my Github</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=164644dc9828" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/deploying-jakarta-ee-9-applications-to-apache-tomee-using-cargo-maven-plugin-164644dc9828">Deploying Jakarta EE 9 applications to Apache TomEE using Cargo maven plugin</a> was originally published in <a href="https://itnext.io">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>

  </article>

  

</div>

  </div>

  <!-- Footer -->

  
<footer class="fixed-bottom">
  <div class="container mt-0">
    &copy; Copyright 2021 Hantsy  Bai.
    <span class="mr-auto"></span>
    Powered by <a href="http://jekyllrb.com/" target="_blank">Jekyll</a> with <a href="https://github.com/alshedivat/al-folio">al-folio</a> theme.

    
    

  </div>
</footer>



</body>

<!-- Bootsrap & MDB scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.4.4/umd/popper.min.js" integrity="sha512-eUQ9hGdLjBjY3F41CScH3UX+4JDSI9zXeroz7hJ+RteoCaY+GP/LDoM8AO+Pt+DRFw3nXqsjh9Zsts8hnYv8/A==" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha512-M5KW3ztuIICmVIhjSqXe01oV2bpe248gOxqmlcYrEzAvws7Pw3z6BK0iGbrwvdrUQUhi3eXgtxp5I8PDo9YfjQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.19.1/js/mdb.min.js" integrity="sha512-Mug9KHKmroQFMLm93zGrjhibM2z2Obg9l6qFG2qKjXEXkMp/VDkI4uju9m4QKPjWSwQ6O2qzZEnJDEeCw0Blcw==" crossorigin="anonymous"></script>


<!-- Mansory & imagesLoaded -->
<script defer src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
<script defer src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>
<script defer src="/assets/js/mansory.js" type="text/javascript"></script>





<!-- Load Common JS -->
<script src="/assets/js/common.js"></script>


</html>
